package com.xin.bi.controller;

import com.xin.bi.common.BaseResponse;
import com.xin.bi.exception.BusinessException;
import com.xin.bi.model.dto.user.UserLoginRequest;
import com.xin.bi.model.vo.LoginUserVO;
import com.xin.bi.service.UserService;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.CompletableFuture;

@RestController
public class UserController {
    @Resource
    private UserService userService;


    /**
     * 单点登录
     * @param userLoginRequest
     * @param httpServletRequest
     * @return
     */
    @PostMapping("/login")
    public BaseResponse<LoginUserVO> login(@RequestBody UserLoginRequest userLoginRequest, HttpServletRequest httpServletRequest){
        if (userLoginRequest==null){
            throw new  BusinessException("参数有误git版本1");
        }
        LoginUserVO loginUserVO = userService.login(userLoginRequest.getUserAccount(), userLoginRequest.getUserPassword(), httpServletRequest);
        return new BaseResponse<>(true,loginUserVO,"登录成功");
    }

}
